package com.os.osframe.scaffold.java.web

{packages}.web;

import javax.annotation.Resource;
import com.os.osframe.frame.service.IBaseService;
import com.os.osframe.frame.web.BaseController;
import com.os.osframe.${packages}.domain.${domain};
import com.os.osframe.${packages}.service.I${domain}Service;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import com.os.osframe.frame.common.HqlObject;
import com.os.osframe.frame.common.RequiresClassAuth;
import com.os.osframe.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * ${info}
 * Created by ${author} on ${time}.
 */
@Controller
@RequestMapping(value = "${domainPath}")
@RequiresClassAuth
public class ${domain}Controller extends BaseController<${domain}> {
    @Resource
    I${domain}Service ${domainVar}Service;
    @Override
    protected IBaseService getServiceImp() {
        return ${domainVar}Service;
    }

    @Override
    protected void changeSearchHqlObject(HttpServletRequest request, HqlObject hqlObject) throws Exception {
        super.changeSearchHqlObject(request, hqlObject);
        String where="";
        String searchKey=request.getParameter("searchKey");
        if(StringUtil.isNotNull(searchKey)){
        where=" ${domainVar}.lbName like :searchKey";
        hqlObject.setParameter("searchKey","%"+searchKey+"%");
        }
        hqlObject.setWhereExtract(StringUtil.linkString(hqlObject.getWhereExtract()," and ",where));
    }
}
